/**
 * 测试fork函数使用，父进程返回子进程pid，子进程返回0；
 * @author: sundx
 * @date: 2020-05-30 22:00:29
 * @Last Modified by: sundx
 * @Last Modified time: 2020-05-30 22:01:01
 */
#include <iostream>
#include <unistd.h>
int main() {
  pid_t pid;
  int i;
  for (i = 0; i < 5; ++i) {
    if ((pid = fork()) == 0)
      break;
  }
  if (pid) {
    std::cout << "parent" << std::endl;
  } else {
    std::cout << i + 1 << std::endl;
  }
}